<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
 <title>Git提交记录列表</title>
<script type="text/javascript" src="/js/vue.js"></script>
<script type="text/javascript" src="/js/axios.min.js"></script>
<link href="/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<div id="app" class="container-fluid">
        <!--        检索栏  start   -->
        <div class="d-flex">
                <div class="p-2">
                    <form>
                        <div class="form-row align-items-center">
                            <div class="col-auto my-1">
                                <label class="mr-sm-2 sr-only" for="inlineFormCustomSelect">Preference</label>
                                <select class="custom-select mr-sm-2" v-model="selectedAuthor" id="inlineFormCustomSelect" @change="queryByAuthor()">
                                    <option selected>作者...</option>
                                    <option v-for="item in authors"  :value="item.author">{{item.author}}</option>
                                </select>
                            </div>
                            <div class="col-auto my-1">
                                <button type="button" class="btn btn-primary" @click="genertateScript()">生成脚本</button>
                            </div>
                        </div>
                    </form>
                </div>

                <div class="ml-auto p-2">
                    <div class="form-group mx-sm-3 mb-2">
                        <input type="text" class="form-control" @keyup.enter="updateVersion" v-model="version"   style="width: 120px;" placeholder="版本">
                    </div>
                </div>
        </div>
        <!--        检索栏  end   -->


        <table class="table" border="1">
            <thead>
                <tr >
                    <td>S</td>
                    <td>Name</td>
                    <td>Date</td>
                    <td align="center">Description</td>
                </tr>
            </thead>
            <tbody>
            <!-- template不会被渲染 -->
            <template v-for="(item,index) in commitRecords">
                    <tr  :key="item.commitId" class="table-primary">
                        <td>
                            <div class="form-check">
                                <input type="checkbox"
                                       name="parent"
                                       :value="item.commitId"
                                       v-model="parentSelected"
                                       @click="selectGroup(item)"

                                    />
                            </div>

                        </td>
                        <td>{{item.author}}</td>
                        <td>{{item.date}}</td>
                        <td >
                            {{item.remark}}
                        </td>
                    </tr>
                    <tr  v-for="(line,index) in item.lines">
                        <td>
<!--                            <div class="form-check">-->
<!--                                <input class="form-check-input" type="checkbox" value="" >-->

<!--                            </div>-->
                            <div class="input-group-text">
                                <input
                                        type="checkbox"
                                        name="GitCommitRecordArray"
                                        v-model="selectedArray"
                                        :value="line.id"
                                        :checked="line.selected"

                                />
                            </div>
                        </td>
                        <td colspan="3">[{{line.status}}]&nbsp;&nbsp; {{line.line}}</td>
                    </tr>
            </template>
            </tbody>
        </table>
    </div>

</div>


<script>

    var v = new Vue({
        el: "#app",
        data: {
            commitRecords:[],
            parentDir:"",
            currentDir:"",
            id:"123",
            selected:false,
            selectedArray:[],
            parentSelected:[],
            version:"9.9.9.9",
            authors:[
                {author:"lisuyun",  name:"李素云"},
                {author:"zhoubaojian",  name:"周报坚"},
                {author:"ouyangchuangqi",  name:"欧阳创奇"},
                {author:"tangxiangqian",  name:"唐湘黔"},
                {author:"linhy",  name:"林宏勇"},
                {author:"fengxianbin",  name:"冯显斌"},
                {author:"lufangbu",  name:"卢方卜"},
                {author:"liuchengbo",  name:"刘成波"},
                {author:"guhaijiang",name:"谷海江"},
                {author:"zhouchong",name:"周冲"},


            ],
            selectedAuthor:"作者...",
        },


        methods: {

            queryGitRecord: function () {
                var vueObj = this;
                axios.get("/git/commit/records").then(function (resp) {
                    vueObj.commitRecords = resp.data;
                    console.log("==== vueObj.commitRecords",vueObj.commitRecords)
                   // vueObj.parentDir = resp.data.data.parentDir
                   // vueObj.currentDir = resp.data.data.currentDir
                })
            },
            fsDownload(relativePath){
                window.location.href="/release/fs/download?relativePath="+relativePath;
            },
            selectGroup(row){
                let selected = row.selected;
                let commitId = row.commitId;
                if(!selected){
                    // 修改成选中状态
                    row.selected = true;
                    this.commitRecords.forEach(item => {
                        let lines = item.lines;
                        lines?.forEach(detail => {
                            //console.log("*** line:",detail.id)
                            if(detail.id.includes(commitId)){
                                // 选中
                                detail.selected = true;
                                this.selectedArray.push(detail.id);
                            }
                        })
                    })

                }else {
                    // 取消选中
                    row.selected = false;
                    for(let i=this.selectedArray.length; i>0 ;i--){
                        let  id = this.selectedArray[i-1];
                        if(id.includes(commitId)){
                            // 选中
                            //detail.selected = false;
                            this.selectedArray.splice(i-1,1);
                        }

                    }


                }

            },
            genertateScript(){
                if(this.version === '' || this.version === null){
                    alert(" 发版代码[增量]提取版本不能为空！");
                    return;
                }
                alert(" 当前编译的代码版本号："+this.version);
                var vueObj = this;
                let params = {idList:this.selectedArray,version:this.version}
                axios.post("/git/generate/script",params)
                    .then(function (resp) {
                    let result = resp.data;
                    vueObj.selectedArray=[];
                    vueObj.parentSelected=[];
                    console.log(" ====== 返回结果：",result);
                    //alert(result.code)
                     alert("生成脚本["+vueObj.version+"] 成功！")
                });



            },

            /**
             * 更新version
             */
            updateVersion(){
              //  /update/version
                let vueObj = this;
                axios.get("/git/update/version?version="+this.version)
                    .then(function (resp) {
                        let result = resp.data.data;
                        vueObj.version = result;
                        alert("版本["+vueObj.version+"] 更新成功！")
                    });
            },

            /**
             * 查询version
             */
            queryVersion(){
                //  /update/version
                let vueObj = this;
                axios.get("/git/find/version")
                    .then(function (resp) {
                        let result = resp.data.data;
                        vueObj.version = result;
                    });
            },
            queryByAuthor(){
                var vueObj = this;
                axios.get("/git/commit/query?author="+this.selectedAuthor)
                    .then(function (resp) {
                        let result = resp.data.data;
                        vueObj.commitRecords = result;
                    });
            },


    },
        mounted: function () {
            this.queryGitRecord();
            // 查询版本
            this.queryVersion();
        },

    })


</script>


</body>
</html>

===========================

模板开发==>生成页==>数据配置

===========================